<template>
  <el-container class="home-container">
    <!-- 头部区域 -->
    <el-header>
      <div>
        <img src="../assets/logo.png" style="width:60px;height:60px" alt />
        <span>嘻莱商户数据系统</span>
      </div>
      <el-button type="info" @click="out">退出</el-button>
    </el-header>
    <el-container>
      <!-- 左侧边栏 -->
      <el-aside :width="iscollapse ? '169px':'169px'">
        <!-- 点击缩小侧边栏 -->
        <div class="widthbutton">||||</div>
        <!-- 菜单栏 -->
        <el-menu
          background-color="#333744"
          text-color="#fff"
          active-text-color="#409eff"
          :unique-opened="true"
          :collapse="iscollapse"
          :collapse-transition="false"
          router
          :default-active="$route.path"
        >
          <!-- 一级菜单区域 -->
          <el-submenu :index="item.id+''" v-for="item in menuList" :key="item.id">
            <template slot="title">
              <!-- 图标 -->
              <i :class="iconObj[item.id]"></i>
              <!-- 文本 -->
              <span>{{item.authName}}</span>
            </template>
            <!-- 二级菜单区域 -->
            <el-menu-item
              :index="'/'+subitem.path"
              v-for="subitem in item.children"
              :key="subitem.id"
            >
              <template>
                <!-- 图标 -->
                <i class="el-icon-menu"></i>
                <!-- 文本 -->
                <span>{{subitem.authName}}</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 右侧边栏 -->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import { menuList, kefuList, iconObj } from "../../public/js/menu";
export default {
  data() {
    return {
      menuList: menuList,
      iconObj: iconObj,
      iscollapse: false
    };
  },
  name: "home",
  created() {},
  methods: {
    out() {
      window.localStorage.removeItem("token");
      window.localStorage.removeItem("password");
      window.localStorage.removeItem("account");
      this.$router.push("/login");
    },
    asideSmall() {
      this.iscollapse = !this.iscollapse;
    }
  }
};
</script>

<style lang="less" scoped>
.home-container {
  height: 100%;
}
.el-header {
  padding-left: 0;
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  > div {
    color: #fff;
    font-size: 25px;
    img {
      padding-right: 30px;
      vertical-align: middle;
    }
  }
}
.el-aside {
  background-color: #333744;
}
.el-main {
  background-color: #eaedf1;
}
.iconfont {
  margin-right: 10px;
  vertical-align: middle;
}
.el-menu {
  border-right: none;
}
.widthbutton {
  color: #fff;
  font-size: 10px;
  line-height: 30px;
  text-align: center;
  letter-spacing: 0.5em;
  background-color: #222f3e;
  cursor: pointer;
}
</style>